package someclass;
import java.util.Scanner;

public class Bibioteca {
    public static void main(String[] args){
        userLogin login = new userLogin();
        login.showWelcome();
        login.showPromptMessage();
        printMessage("UserName:");
        String userNameInfo = getInputFromKeyboard();
        printMessage("UserPassword:");
        String userPasswordInfo = getInputFromKeyboard();
        boolean loginJudge = login.checkUsername(userNameInfo,userPasswordInfo);
        if(loginJudge){
            showMenuOptionList showOptionList = new showMenuOptionList();
            showOptionList.show();
            int optionNumber=0;
            try{
                optionNumber=Integer.parseInt(getInputFromKeyboard());
            }   catch (Exception e){
                optionNumber=-1;
                printMessage("wrong input;"+e.toString());
                return;
            }
            String putout = showOptionList.select(optionNumber);
            printMessage(putout);

            if(showOptionList.couldReserveBook){
                reserveBook reserve = new reserveBook();
                reserve.showPromptMessage();
                int reserveNumber=0;
                try{
                    reserveNumber=Integer.parseInt(getInputFromKeyboard());
                }   catch (Exception e){
                    printMessage("wrong:"+e.toString());
                    reserveNumber=-1;
                    return;
                }
                putout = reserve.doreserve(reserveNumber);
                System.out.println(putout);
            }
            else if(showOptionList.showBooklist){
                showBookList booklist = new showBookList();
                booklist.showTitle();
                booklist.showBookInfoList();
            }
            else if(showOptionList.showMovieDetails){
                movieDetails theMovieDetails = new movieDetails();
                theMovieDetails.showTitle();
                theMovieDetails.showMovieInfoList();
            }
        }
        else{
             String loginWrong;
             loginWrong = login.showWrongMessage();
            printMessage(loginWrong);
        }
    }

    public static String getInputFromKeyboard(){
        Scanner in=new Scanner(System.in);
        String theInput = in.nextLine();
        return theInput;
    }
    private static void printMessage(String message){
        System.out.println(message);
    }
}
